<template>
	<view class="body">
		<myHeader :title="title"></myHeader>
		<!-- <uni-search-bar @confirm="sreachIt()" :focus="false" v-model="search" @clear="search=''"></uni-search-bar> -->
		<view v-if="currentRoleCode.includes('fl-leader')">
			<uni-fab :pattern="btnPattern" @fabClick="pageTo('./add')"></uni-fab>
		</view>
		<!-- 人物列表 -->
		<uni-list v-for="(item,index) in teamList" :key="item.id">
			<uni-list-item :title="item.teamName==null?'无标题':item.teamName" link="navigateTo"
				@click="pageTo1('./detail',item)" :note="item.leaderName">
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import myHeader from '../../components/head.vue'
	import NetWorkTool from '@/api/netWorkTool'
	export default {
		data() {
			return {
				title: '妇联团队',
				search: '',
				btnPattern: {
					buttonColor: '#e20909'
				},
				// 当前用户角色
				currentRoleCode: [],
				// 团队列表
				teamList:[{
					id: 1,
					teamName: '团队1',
					leaderName:'曹'
				},{
					id: 2,
					teamName: '团队2',
					leaderName:'朱'
				}]
			}
		},
		created() {
			this.getLoginUserRoles();
			this.getGroups();
		},
		methods: {
			
			// 查询小组
			getGroups(){
				
				NetWorkTool.POST('/api/federation-teams-relation/getTeams',{},true).then(res=>{
					this.teamList = res
				})
				
			},
			// 获取登录用户角色
			getLoginUserRoles() {
				let _this = this;
				uni.getStorage({
					key: 'user',
					success(e) {
						let arr = [];
						for (let item of e.data.role) {
							if (null != item.roleCode) {
								_this.currentRoleCode.push(item.roleCode)
							}
						}
					}
				})
			},
			pageTo(val) {
				uni.navigateTo({
					url: val
				})
			},
			pageTo1(val,data) {
				uni.navigateTo({
					url: val + "?data=" + JSON.stringify(data)
				})
			},
			
		},
		components: {
			myHeader
		},
	}
</script>

<style>
</style>
